package com.acmetelecom.core;

import java.math.BigDecimal;
import java.util.List;

import com.acmetelecom.customer.Customer;
import com.acmetelecom.utils.Printer;

public class BillGenerator {
    protected Printer printer;

    public BillGenerator(Printer printer) {
    	this.printer = printer;
    }

	public void send(Customer customer, List<LineItem> calls) {
		BigDecimal total = BigDecimal.ZERO;
        printer.printHeading(customer.getFullName(), customer.getPhoneNumber(), customer.getPricePlan());
        for (LineItem call : calls) {
            printer.printItem(call.date(), call.callee(), call.durationMinutes(), call.cost());
            total = total.add(call.cost());
        }
        printer.printTotal(total);
    }

}
